package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.AllianceSettlement;
import com.eling.elcms.travel.model.GroupReserve;
import com.eling.elcms.travel.model.view.AllianceSetlGridView;
import com.eling.elcms.travel.model.view.AllianceSetlSaveView;
import com.eling.elcms.travel.service.IAllianceSettlementManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class AllianceSettlementController extends BaseFormController{

	@Autowired
	private IAllianceSettlementManager allSetlManager;
	
	@RequestMapping("/api/alliancesettlement/save")
    @ResponseBody
	public AllianceSettlement save(@ModelAttribute@ModelFilling AllianceSettlement cond){
		return allSetlManager.save(cond);
	}
	
	@RequestMapping("/api/alliancesettlement/{pkAllianceSettlement}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkAllianceSettlement){
		allSetlManager.remove(pkAllianceSettlement);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/alliancesettlement/query")
    @ResponseBody
	public List<AllianceSettlement> query(@ModelAttribute AllianceSettlement cond){
		return allSetlManager.query(cond);
	}
	
	@RequestMapping("/api/alliancesettlement/search*")
	@ResponseBody
	public List<AllianceSettlement> search(@ModelAttribute SearchCondition sc,@ModelAttribute AllianceSettlement cond){
		sc.setQueryCondition(cond);
		return allSetlManager.search(sc);
	}
	
	/**
	 * 查询入住联盟结算列表数据
	 * @param cond
	 * @return
	 * @author zhoulin
	 */
	@RequestMapping("/api/alliancesettlement/querysetl")
    @ResponseBody
	public List<AllianceSetlGridView> querySetl(@ModelAttribute GroupReserve cond){
		return allSetlManager.querySetl(cond);
	}
	
	/**
	 * 入住联盟结算保存
	 * @param assView
	 * @return
	 * @author zhoulin
	 */
	@RequestMapping("/api/alliancesettlement/savesetl")
    @ResponseBody
	public Msg saveSetl(@ModelAttribute AllianceSetlSaveView assView){
		return allSetlManager.saveSetl(assView);
	}
	
}
